<?php
function_exists('UnixPath')  || die('OK');
$ACT = array('list', 'add', 'aok', 'edit', 'eok', 'del');
in_array($_GET['act'], $ACT) || $_GET['act'] = 'list';
	$_GET['id']	= (int) $_GET['id'];

$body['navlist'] = array(
		'list' => '管理员列表',
		'add' => '添加管理员',
	);

	$G = E::$DB->ary('_admin_group', 1, '*', 'id'); 

if( $_GET['act'] == 'glist' ){
	$p = E::$DB->page('_admin_group');
	$L = E::$DB->all('_admin_group', '1 ' . $p['limit']);
	$body['node_tree'] = "<a href=\"?mod=$_GET[mod]&fun=group&act=list\">管理员组</a> ";
}else{
	empty($G[$_GET['gid']]) && $_GET['gid'] =1; $_G = $G[$_GET['gid']];
	$body['node_tree'] = '';
	$body['_url'] = '&gid='. $_GET['gid'];	
	$body['node_tree'] = "<a href=\"?mod=$_GET[mod]&fun=group&act=list\">管理员组</a> <small>&gt;&gt;</small> <a href=\"$html[url]&act=list&gid=$_GET[gid]\">$_G[name]</a>";
}

$body['url'] = $html['url'] . $body['_url'];

//E::$DB->_tab = '_admin_user'; 

if( $_GET['act']=='aok' ){
	$_POST['passwd']	=	md5($_POST['passwd']);
	E::$DB->insert('_admin_user', 'name,gid,passwd');
	A::msg('添加组完成!', $_POST['jurl'] , 1, 1);
}


if( $_GET['act'] == 'edit' ){
	$html['tpl_right_act'] = 'add';
	$L = E::$DB->one('_admin_user', 'id=' . $_GET['id']);
	$L['id'] || msg("无效的节点", $_POST['jurl'], 3, 1 );
}


if( $_GET['act'] == 'eok' ){
	$L = E::$DB->one('_admin_user', 'id=' . $_GET['id']);
	$L['id'] || msg("无效的选项!", $_POST['jurl'], 3, 1 );
		$_POST['passwd'] = md5($_POST['passwd']);
	E::$DB->update('_admin_user',  'name ,gid ,passwd', 'id=' . $L['id']);	
	A::msg("修改 $_POST[name] 完成!", $_POST['jurl'], 3, 1 );
}


if( $_GET['act'] == 'del' ){
	E::$L = $DB->one('_admin_user', 'id='. $_GET['id']);
	$L['id'] || msg('无效的节点', $_POST['jurl'], 3, 1 );
	E::$DB->query('DELETE FROM ' . $DB->_tab . ' where id='. $L['id']);
	A::msg('删除节点 ' . $L['name'] . ' 完成!', $_POST['jurl'], 3, 1 );
}


if( $_GET['act'] == 'list' ){
	$p = E::$DB->page('_admin_user', 'gid=' . $_G['id']  );
	$L = E::$DB->all('_admin_user', 'gid=' . $_G['id'] . '  ' . $p['limit']);
}

